<?php

/**
 * This is the model class for table "zy_order".
 *
 * The followings are the available columns in table 'zy_order':
	 * @property integer $order_id
	 * @property string $orderNo
	 * @property string $phone_connection
	 * @property string $phone_number
	 * @property string $contract
	 * @property string $need_modem
	 * @property string $phone_line_rental
	 * @property string $installation
	 * @property string $eset_security
	 * @property string $home_phone_handset
	 * @property string $modem_data_offer
	 * @property string $title
	 * @property string $first_name
	 * @property string $last_name
	 * @property string $birthdate
	 * @property string $account
	 * @property string $account_text
	 * @property string $phone
	 * @property string $mobile
	 * @property string $email
	 * @property string $confirmEmail
	 * @property string $delivery_radio
	 * @property string $street_number
	 * @property string $street_name
	 * @property string $suburb
	 * @property string $type_state
	 * @property string $postcode
	 * @property string $pay_method
	 * @property string $card_type
	 * @property string $card_name
	 * @property string $card_number
	 * @property string $card_type_month
	 * @property string $card_type_year
	 * @property string $cvv2
	 * @property string $account_name
	 * @property string $account_number
	 * @property string $bsb
	 * @property string $overseacalls
	 * @property string $smartTV
	 * @property string $customer_source
	 * @property integer $order_status
	 * @property string $setup_fee
	 * @property string $modem_fee
	 * @property string $month_fee
	 * @property string $delivery_fee
	 * @property string $installation_fee
	 * @property string $eset_security_fee
	 * @property string $home_phone_handset_fee
	 * @property string $modem_data_offer_fee
	 * @property string $international_calls_fee
	 * @property string $smart_tv_fee
	 * @property string $remark
	 * @property integer $isdelete
	 * @property string $update_user
	 * @property string $update_time
	 * @property string $create_user
	 * @property string $create_time
 */
class Order extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Order the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'zy_order';
	}
	public function primaryKey()
	{
		return 'order_id';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('order_status, isdelete', 'numerical', 'integerOnly'=>true),
			array('referral_id,orderNo, phone_connection, phone_number, contract, need_modem, phone_line_rental, installation, eset_security, home_phone_handset, modem_data_offer, title, first_name, last_name, birthdate, account, account_text, phone, mobile, email, confirmEmail, delivery_radio, street_number, street_name, suburb, type_state, postcode, pay_method, card_type, card_name, card_number, card_type_month, card_type_year, cvv2, account_name, account_number, bsb, overseacalls, smartTV, customer_source, setup_fee, modem_fee, month_fee, delivery_fee, installation_fee, eset_security_fee, home_phone_handset_fee, modem_data_offer_fee, international_calls_fee, smart_tv_fee, remark, update_user, create_user', 'length', 'max'=>255),
			array('update_time, create_time', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('order_id, orderNo, phone_connection, phone_number, contract, need_modem, phone_line_rental, installation, eset_security, home_phone_handset, modem_data_offer, title, first_name, last_name, birthdate, account, account_text, phone, mobile, email, confirmEmail, delivery_radio, street_number, street_name, suburb, type_state, postcode, pay_method, card_type, card_name, card_number, card_type_month, card_type_year, cvv2, account_name, account_number, bsb, overseacalls, smartTV, customer_source, order_status, setup_fee, modem_fee, month_fee, delivery_fee, installation_fee, eset_security_fee, home_phone_handset_fee, modem_data_offer_fee, international_calls_fee, smart_tv_fee,referral_id, remark, isdelete, update_user, update_time, create_user, create_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'order_id' =>Yii::t("Order","Order ID"),
			'referral_id'=>Yii::t("Order", "referral ID"),
			'orderNo' =>Yii::t("Order","Order No"),
			'phone_connection' =>Yii::t("Order","Phone Connection"),
			'phone_number' =>Yii::t("Order","Phone Number"),
			'contract' =>Yii::t("Order","Contract"),
			'need_modem' =>Yii::t("Order","Need Modem"),
			'phone_line_rental' =>Yii::t("Order","Phone Line Rental"),
			'installation' =>Yii::t("Order","Installation"),
			'eset_security' =>Yii::t("Order","Eset Security"),
			'home_phone_handset' =>Yii::t("Order","Home Phone Handset"),
			'modem_data_offer' =>Yii::t("Order","Modem Data Offer"),
			'title' =>Yii::t("Order","Title"),
			'first_name' =>Yii::t("Order","First Name"),
			'last_name' =>Yii::t("Order","Last Name"),
			'birthdate' =>Yii::t("Order","Birthdate"),
			'account' =>Yii::t("Order","Account"),
			'account_text' =>Yii::t("Order","Account Text"),
			'phone' =>Yii::t("Order","Phone"),
			'mobile' =>Yii::t("Order","Mobile"),
			'email' =>Yii::t("Order","Email"),
			'confirmEmail' =>Yii::t("Order","Confirm Email"),
			'delivery_radio' =>Yii::t("Order","Delivery Radio"),
			'street_number' =>Yii::t("Order","Street Number"),
			'street_name' =>Yii::t("Order","Street Name"),
			'suburb' =>Yii::t("Order","Suburb"),
			'type_state' =>Yii::t("Order","Type State"),
			'postcode' =>Yii::t("Order","Postcode"),
			'pay_method' =>Yii::t("Order","Pay Method"),
			'card_type' =>Yii::t("Order","Card Type"),
			'card_name' =>Yii::t("Order","Card Name"),
			'card_number' =>Yii::t("Order","Card Number"),
			'card_type_month' =>Yii::t("Order","Card Type Month"),
			'card_type_year' =>Yii::t("Order","Card Type Year"),
			'cvv2' =>Yii::t("Order","Cvv2"),
			'account_name' =>Yii::t("Order","Account Name"),
			'account_number' =>Yii::t("Order","Account Number"),
			'bsb' =>Yii::t("Order","Bsb"),
			'overseacalls' =>Yii::t("Order","Overseacalls"),
			'smartTV' =>Yii::t("Order","Smart Tv"),
			'customer_source' =>Yii::t("Order","Customer Source"),
			'order_status' =>Yii::t("Order","Order Status"),
			'setup_fee' =>Yii::t("Order","Setup Fee"),
			'modem_fee' =>Yii::t("Order","Modem Fee"),
			'month_fee' =>Yii::t("Order","Month Fee"),
			'delivery_fee' =>Yii::t("Order","Delivery Fee"),
			'installation_fee' =>Yii::t("Order","Installation Fee"),
			'eset_security_fee' =>Yii::t("Order","Eset Security Fee"),
			'home_phone_handset_fee' =>Yii::t("Order","Home Phone Handset Fee"),
			'modem_data_offer_fee' =>Yii::t("Order","Modem Data Offer Fee"),
			'international_calls_fee' =>Yii::t("Order","International Calls Fee"),
			'smart_tv_fee' =>Yii::t("Order","Smart Tv Fee"),
			'referral_id' =>Yii::t("Order","Referral Id"),
			'remark' =>Yii::t("Order","Remark"),
			'isdelete' =>Yii::t("Order","Isdelete"),
			'update_user' =>Yii::t("Order","Update User"),
			'update_time' =>Yii::t("Order","Update Time"),
			'create_user' =>Yii::t("Order","Create User"),
			'create_time' =>Yii::t("Order","Create Time"),
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search($create_time)
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('order_id',$this->order_id);
		$criteria->compare('referral_id',$this->referral_id);
		$criteria->compare('orderNo',$this->orderNo,true);
		$criteria->compare('phone_connection',$this->phone_connection,true);
		$criteria->compare('phone_number',$this->phone_number,true);
		$criteria->compare('contract',$this->contract,true);
		$criteria->compare('need_modem',$this->need_modem,true);
		$criteria->compare('phone_line_rental',$this->phone_line_rental,true);
		$criteria->compare('installation',$this->installation,true);
		$criteria->compare('eset_security',$this->eset_security,true);
		$criteria->compare('home_phone_handset',$this->home_phone_handset,true);
		$criteria->compare('modem_data_offer',$this->modem_data_offer,true);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('first_name',$this->first_name,true);
		$criteria->compare('last_name',$this->last_name,true);
		$criteria->compare('birthdate',$this->birthdate,true);
		$criteria->compare('account',$this->account,true);
		$criteria->compare('account_text',$this->account_text,true);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('mobile',$this->mobile,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('confirmEmail',$this->confirmEmail,true);
		$criteria->compare('delivery_radio',$this->delivery_radio,true);
		$criteria->compare('street_number',$this->street_number,true);
		$criteria->compare('street_name',$this->street_name,true);
		$criteria->compare('suburb',$this->suburb,true);
		$criteria->compare('type_state',$this->type_state,true);
		$criteria->compare('postcode',$this->postcode,true);
		$criteria->compare('pay_method',$this->pay_method,true);
		$criteria->compare('card_type',$this->card_type,true);
		$criteria->compare('card_name',$this->card_name,true);
		$criteria->compare('card_number',$this->card_number,true);
		$criteria->compare('card_type_month',$this->card_type_month,true);
		$criteria->compare('card_type_year',$this->card_type_year,true);
		$criteria->compare('cvv2',$this->cvv2,true);
		$criteria->compare('account_name',$this->account_name,true);
		$criteria->compare('account_number',$this->account_number,true);
		$criteria->compare('bsb',$this->bsb,true);
		$criteria->compare('overseacalls',$this->overseacalls,true);
		$criteria->compare('smartTV',$this->smartTV,true);
		$criteria->compare('customer_source',$this->customer_source,true);
		$criteria->compare('order_status',$this->order_status);
		$criteria->compare('setup_fee',$this->setup_fee,true);
		$criteria->compare('modem_fee',$this->modem_fee,true);
		$criteria->compare('month_fee',$this->month_fee,true);
		$criteria->compare('delivery_fee',$this->delivery_fee,true);
		$criteria->compare('installation_fee',$this->installation_fee,true);
		$criteria->compare('eset_security_fee',$this->eset_security_fee,true);
		$criteria->compare('home_phone_handset_fee',$this->home_phone_handset_fee,true);
		$criteria->compare('modem_data_offer_fee',$this->modem_data_offer_fee,true);
		$criteria->compare('international_calls_fee',$this->international_calls_fee,true);
		$criteria->compare('smart_tv_fee',$this->smart_tv_fee,true);
		$criteria->compare('referral_id',$this->referral_id,true);
		$criteria->compare('remark',$this->remark,true);
		$criteria->compare('isdelete',$this->isdelete);
		$criteria->compare('update_user',$this->update_user,true);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('create_user',$this->create_user,true);		
		if($this->create_time=="")
		$criteria->compare('create_time',$this->create_time,true);
		else
		$criteria->addBetweenCondition('create_time', $this->create_time . " 00:00:00", $create_time . " 23:59:59");
		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
			'sort'=>array(  
           		 'defaultOrder'=>'order_id DESC',  
       		 ),  
       		'pagination'=>array(  
           		 'pageSize'=>20  
       		 ),  
		));
	}
}